package org.wlc.demov3;

import org.wlc.demov3.store.ICommodity;
import org.wlc.demov3.store.impl.CardCommodityService;
import org.wlc.demov3.store.impl.CouponCommodityService;
import org.wlc.demov3.store.impl.GoodsCommodityService;

/**
 * @author 王立朝
 * @date 2022/5/27
 * @description:
 */
public class StoreFactory {

    public ICommodity getCommodityService(Integer commodityType) {
        if (null == commodityType) {
            return null;
        }
        if (1 == commodityType) {
            // 第三方兑换卡
            return new CardCommodityService();
        }
        if (2 == commodityType) {
            // 优惠券
            return new CouponCommodityService();
        }
        if (3 == commodityType) {
            // 实物商品
            return new GoodsCommodityService();
        }
        throw new RuntimeException("不存在的商品服务类型！");
    }
}
